package day06;

import javax.swing.*;
import java.awt.*;

public class Demo02 {
    public static void main(String[] args) {
        JFrame f = new JFrame("第二个窗体");
        f.setSize(400,400);
        f.setResizable(false);
        f.setLocationRelativeTo(null);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        MyPanel mp = new MyPanel();
        f.add(mp);

        f.setVisible(true);
    }
}

class MyPanel extends JPanel{
    //用来绘图的方法
    @Override
    public void paint(Graphics g){
        //从150,150位置画一个圆
        g.setColor(Color.GREEN);
        g.drawOval(150,150,100,100);
        g.fillOval(20,20,50,50);
        g.setColor(Color.RED);
        g.drawRect(100,50,120,60);

        g.drawLine(40,40,200,200);
        g.setColor(new Color(241,247,28));
        //设置字体大小
        g.setFont(new Font("宋体",Font.BOLD,80));
        g.drawString("*",80,50);
    }
}
